package com.sh.data.engine.domain.integration.offline.model.domain;

import com.sh.data.engine.domain.shims.db.model.TableInfoDomain;
import lombok.Builder;
import lombok.Data;
import lombok.experimental.Tolerate;

import java.util.List;

@Data
@Builder(toBuilder = true)
public class OfflineTaskExistTableMappingDomain {

    private List<Table> tables;

    @Data
    @Builder(toBuilder = true)
    public static class Table {
        /**
         * 表名
         */
        private String tableName;

        /**
         * 表类型
         */
        private TableInfoDomain.TblType tblType;

        /**
         * 是否是分区表
         */
        private boolean isPartitionTable;

        /*分区字段*/
        private List<Field> partitionFields;

        private List<Field> fields;

        @Tolerate
        public Table() {
        }
    }

    @Data
    @Builder(toBuilder = true)
    public static class Field {
        /**
         * 字段名
         */
        private String fieldName;

        /**
         * 字段类型（从db中读取到的）
         */
        private String fieldType;

        /**
         * 字段类型（对应的java.sql.Types的SQL类型）
         */
        private int dataType;

        /**
         * 字段长度
         */
        private Integer columnSize;

        /**
         * 字段小数位长度
         */
        private Integer decimalDigits;

        /**
         * 是否是分区字段
         */
        private Boolean isPartition;

        /**
         * 字段是否是主键
         */
        private boolean isPk;

        /**
         * 字段可否为空
         */
        private boolean isNullable;

        /**
         * 字段备注
         */
        private String comment;

        @Tolerate
        public Field() {
        }
    }

    @Tolerate
    public OfflineTaskExistTableMappingDomain() {
    }
}
